import request from '../utils/request'
//添加主评论
export const addComment=(data:any)=>{
    return request.post('/reviews',data)
}
//添加回复评论
export const addReply=(data:any)=>{
    return request.post('/reviews/reply',data)
}
//获取指定商品的所有评论
export const getProductComment=(itemId:number)=>{
    return request.get('/reviews',{params:{itemId}})
}
//获取当前用户对指定商品的所有评论
export const getUserComment=(itemId:number)=>{
    return request.get('/reviews/current',{params:{itemId}})
}
//获取评论的回复
export const getCommentReply=(parentId:number)=>{
    return request.get('/reviews/replies',{params:{parentId}})
}
//删除评论
export const deleteComment=(id:number)=>{
    return request.delete(`/reviews/${id}`)
}
//更新评论
export const updateComment=(id:number,data:any)=>{
    return request.put(`/reviews/${id}`,data)
}
//获取商品平均评分
export const getProductAverageScore=(itemId:number)=>{
    return request.get('/reviews/average',{params:{itemId}})
}
//获取商品评分分布
export const getProductScoreDistribution=(itemId:number)=>{
    return request.get('/reviews/distribution',{params:{itemId}})
}
